#!/usr/bin/python2.5
#
# (c) 2009 - Chip Turner
#
# Apache License, blah blah, it's a few hundred lines of python.

"""
"""

import os
import re
import time
import sys
import optparse

import armory_lib

def main(args):
  parser = optparse.OptionParser(__doc__)
  parser.add_option("-r", "--realm", help="realm player or guild is on")
  player_group = optparse.OptionGroup(parser, "Player Options")
  player_group.add_option("-p", "--player", help="player name to extract data for")
  parser.add_option_group(player_group)

  options, args = parser.parse_args(args)

  stats = armory_lib.ParseStats(options.realm, options.player, 14807)
  paren_stats = dict()
  p_re = re.compile(r'\((.*)\)')

  for group, group_values in stats.items():
    if group != "Wrath of the Lich King": continue
    for stat_name, value in sorted(group_values):
      m = p_re.search(stat_name)
      if m:
        paren_stats[m.group(1)] = paren_stats.get(m.group(1), 0) + 1
      else:
        print "%-65s: %d" % (stat_name, value)

  print
  for n, v in sorted(paren_stats.items()):
    print "%-35s: %d" % (n, v)

if __name__ == '__main__':
  main(sys.argv[1:])
